# 初始化mcp服务
import uvicorn
from mcp.server import FastMCP
from starlette.applications import Starlette
from starlette.routing import Mount

from application.mcp.block_type_mcp_tool import block_type_tool
from application.mcp.excel_mcp_tool import excel_to_json_array_tool
from application.mcp.interface_implementer_mcp_tool import interface_implementer_tool
from application.mcp.value_constants_mcp_tool import value_constants_tool

mcp_server = FastMCP(
    name='tqt-activity-development-mcp-server'
)
# 添加mcp工具
mcp_server.add_tool(excel_to_json_array_tool)
mcp_server.add_tool(interface_implementer_tool)
mcp_server.add_tool(value_constants_tool)
mcp_server.add_tool(block_type_tool)

# 挂载SSE服务器到ASGI服务器上
app = Starlette(
    routes=[
        Mount('/', app=mcp_server.sse_app()),
    ]
)

if __name__ == '__main__':
    host = '127.0.0.1'
    port = 8001
    print(f'starting 铜雀台活动开发mcp服务 at http://{host}:{port}/sse')
    # 启动mcp服务
    uvicorn.run(app, host=host, port=port)
